#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;
const int N = 2e5 + 10;
int arr[N], tree[N];
int n;
int lowbit(int x)
{
	return x & -x;
}

void add(int x, int v)
{
	for (int i = x; i <= n; i += lowbit(i)) {
		tree[i] += v;
	}
}

int get_sum(int x)
{
	int ans = 0;
	for (int i = x; i >= 1; i -= lowbit(i)) {
		ans += tree[i];
	}
	return ans;
}
int main()
{
	int t;
	scanf("%d", &t);
	while (t--) {
		memset(tree, 0, sizeof(tree));
		memset(arr, 0, sizeof(arr));
		scanf("%d", &n);
		for (int i = 1; i <= n; i++) {
			scanf("%d", &arr[i]);
		}
		int sum = 0;

		for (int i = 1; i <= n; i++) {
			int x = arr[i];
			sum += get_sum(n) - get_sum(x);
			add(x, 1);
		}
		cout << sum << endl;
		if (sum & 1) {
			cout << "NO" << endl;
		}
		else {
			cout << "YES" << endl;
		}
	}
	return 0;
}